package top.lidee.module.clientApi.twice.applet;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import top.lidee.common.dto.AccountInfo;
import top.lidee.common.dto.UserInfo;
import top.lidee.common.service.MerchantService;
import top.lidee.common.util.TokenUtil;
import top.lidee.framework.enums.CommonExceptionEnum;
import top.lidee.framework.result.PageUtils;
import top.lidee.framework.result.ResponseResult;
import top.lidee.framework.web.BaseController;
import top.lidee.repository.model.MtMerchant;
import top.lidee.repository.model.twice.vo.applet.MtMerchantVo;
import top.lidee.utils.StringUtil;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * @author 张一恒
 * @version 1.0
 * @description: 无需拦截接口
 * @date 2024/9/24 09:44
 */
@Api(tags="小程序端-商户相关接口")
@RestController
@AllArgsConstructor
@RequestMapping(value = "/applet/merchant")
public class MtMerchantController extends BaseController {

    private final MerchantService merchantService;

    /**
     * 根据分类id查询商户信息 分页
     */
    @RequestMapping(value = "/conditionalQueries", method = RequestMethod.POST)
    @ApiOperation(value = "根据分类id查询商户信息 分页")
    public ResponseResult conditionalQueries(@RequestBody Map<String, Object> params) {
        ResponseResult responseResult = merchantService.conditionalQueries(params);
        return responseResult;
    }


    /**
     * 搜索栏：根据商户标题(名)/地址,模糊搜索分页
     */
    @RequestMapping(value = "/conditionalLikeQueries", method = RequestMethod.POST)
    @ApiOperation(value = "搜索栏：根据商户标题(名)/地址,模糊搜索分页")
    public ResponseResult conditionalLikeQueries(@RequestBody Map<String, Object> params) {
        ResponseResult responseResult = merchantService.conditionalLikeQueries(params);
        return responseResult;
    }


    /**
     * 点击商户进入商铺，查询商品
     */
    @RequestMapping(value = "/getInfoAShopListByMerchantsId/{merchantsId}", method = RequestMethod.GET)
    @ApiOperation(value = "点击商户进入商铺，查询商品")
    public ResponseResult getInfoAShopListByMerchantsId(@PathVariable("merchantsId") Integer merchantsId) {
        ResponseResult responseResult = merchantService.getInfoAShopListByMerchantsId(merchantsId);
        return responseResult;
    }


    /**
     * 在保证是当前商户下 根据店铺id查询店铺商品
     */
    @RequestMapping(value = "/getStoreById", method = RequestMethod.GET)
    @ApiOperation(value = "在保证是当前商户下 根据店铺id查询店铺商品")
    public ResponseResult getStoreById(@RequestParam("storeId") Integer storeId,
                                       @RequestParam("merchantsId") Integer merchantsId) {
        ResponseResult responseResult = merchantService.getStoreById(storeId,merchantsId);
        return responseResult;
    }


}
